[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
atoi() Convert String to Integer
#include <stdlib.h>
int atoi(string); The integer value of string
const char *string; String to be converted
atoi() converts 'string' to an integer value. atoi() does not
recognize decimal points or exponents. 'string' has the following
format:
[whitespace][sign]digits
where:
whitespace any number of tab or space characters
are ignored
sign + or -
digits one or more decimal digits
Returns: The integer value of 'string'. If 'string' cannot be
converted to an integer, 0 is returned. The return
value is undefined for overflow.
-------------------------------- Example ---------------------------------
The following statements convert a string to an integer and print the
result.
#include <stdlib.h>
char *s;
int i;
main()
{
s = "12345";
i = atoi(s);
printf("%d\n",i);
}
See Also:
atof()
atol()
ecvt()
fcvt()
gcvt()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson